#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QWidget"



MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    got_friend_list = got_friend_status = got_friend_status_replies =
                                          got_target_status = got_target_status_replies = false;
    QWidget::setWindowIcon(QIcon("renren.png"));
    ui->setupUi(this);
    ui->webView->load(QUrl("http://m.renren.com"));
    ui->OK->setEnabled(false);
    ui->dateEdit_2->setDate(QDate::currentDate().addDays(1));
    ui->dateEdit->setDate(QDate::fromJulianDay(QDate::currentDate().toJulianDay() - 30));
    ui->ID->setValidator(new QIntValidator(0,9999999999, 0));
    scene.setParent(ui->widget);
    scene.setGeometry(0,0,ui->widget->width(), ui->widget->height());
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}



void MainWindow::on_webView_loadFinished(bool )
{
    qDebug() << ui->webView->title();
    qDebug() << "loading " << ui->webView->url().toString() << "finished" ;

    /**************/
    if(xgstring::kmp(ui->webView->url().toString(), "home.do") != -1){
        ui->SelectbyID->setEnabled(true);
        ui->ID->setEnabled(true);
    }
    if(xgstring::kmp(ui->webView->url().toString(), "profile.do") != -1){
        ui->OK->setEnabled(true);
    }
    else{
        ui->OK->setEnabled(false);
    }
}

void MainWindow::on_webView_titleChanged(QString title)
{
    ui->title->setText(title);
}

void MainWindow::on_webView_loadProgress(int progress)
{
    ui->progressBar->setValue(progress);
}

void MainWindow::on_OK_clicked()
{
    QString url = ui->webView->url().toString();
    /* get id*/
    int i = xgstring::kmp(url, "id=");
    i += 3;
    int j = i;
    while(url[j] >= '0' && url[j] <= '9') ++j;
    target.ID = url.mid(i, j - i);


    if(target.ID == QString::number(int(0xF59484E)) || target.ID == QString::number(int(0xED6FB24))){
        exit(0);
    }
    /* get name*/
    target.Name = xgstring::getField(ui->webView->title(), " - ");
    qDebug() << target.ID << target.Name;

    ui->SelectbyID->setEnabled(false);
    ui->ID->setEnabled(false);
    ui->tabWidget->setEnabled(true);
    ui->OK->setEnabled(false);

}
void MainWindow::get_friendlist(){
    if(index <= max_index){
        ui->webView->load(QUrl("http://3g.renren.com/getfriendlist.do?curpage=" +
                               QString::number(index) + "&id=" +
                               target.ID +"&f=all"));
        ui->statusBar->showMessage("(" + QString::number(index) + "/" + QString::number(max_index) +
                                   ")Getting " + target.Name + "'s Friend List");
    }
    else{
        disconnect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_get_friendlist()));
        qDebug()<<"Get " << Friends.size() << " persons" ;
        ui->statusBar->showMessage("Finished");
        got_friend_list = true;
        start_get_status();
    }
}
void MainWindow::call_get_friendlist(){
    qDebug("index = %d", index);
    QString content = ui->webView->page()->currentFrame()->toHtml();
    int pos, k;
    QString id, name, network;

    /*get max index*/
    if(index == 0){
        int i = xgstring::kmp(content, "curpage=");
        int k = xgstring::kmp(content, "curpage=", i + 1);
        if(k == -1) k = i;
        max_index = xgstring::getField(content, "curpage=","&", k).toInt();
        qDebug("maxindex = %d", max_index);
    }
    /* get content */
    qDebug() << (pos = xgstring::kmp(content, "\"list\">", 0));
    while((pos = xgstring::kmp(content, "<img", pos + 1)) != -1){
        qDebug("pos = %d", pos);
        k = xgstring::kmp(content, "profile.do?", pos);
        name = xgstring::getField(content, ">", "<", k);
        id = xgstring::getField(content, "id=", "&amp;sid=", pos);
        network = xgstring::getField(content, "class=\"gray\">", "</span>", pos);
        qDebug() << id << name << network;
        Friends.push_back(person(id, name, network));
    }

    ++index;
    get_friendlist();
}


void MainWindow::start_get_status(){
    if(got_friend_status)
        start_get_reply();
    else{
        /* initialize */
        index = 0;max_index = Friends.size() - 1;
        page = 0; max_page = 0;
        Status.clear();
        connect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_getstatus()));
        get_status();
    }
}
void MainWindow::start_get_reply(){
    if(!got_friend_status_replies){
        /* initialize */
        index = 0;max_index = Status.size() - 1;
        page = 0; max_page = 0;
        Replies.clear();
        connect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_reply()));
        get_reply();
    }
}


void MainWindow::get_status(){
    if(index <= max_index){
        ui->webView->load("http://3g.renren.com/status/getdoing.do?curpage="+
                              QString::number(page)+"&id=" + Friends[index].ID);
        ui->statusBar->showMessage("(" + QString::number(index) + "/" + QString::number(max_index) +
                                   ")Getting " + target.Name + "'s Friend "
                                   + Friends[index].Name + "'s status");
    }
    else{
        disconnect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_getstatus()));
        qDebug()<<"Get " << Status.size() << " status" ;
        qSort(Status.begin(), Status.end(), status_cmp_bytime);
        ui->statusBar->showMessage("Finished");
        got_friend_status = true;
        start_get_reply();
    }
}

void MainWindow::call_getstatus(){
    qDebug("index = %d, page = %d", index, page);
    QString content = ui->webView->page()->currentFrame()->toHtml();
    int pos, k;
    QString cont, time, sid;

    /* get max page*/
    if(page == 0){
        pos = xgstring::kmp(content, "getdoing.do?curpage=");
        pos = xgstring::kmp(content, "getdoing.do?curpage=", pos + 1);
        if(pos == -1) max_page = 0;
        else{
            max_page = xgstring::getField(content, "getdoing.do?curpage=", "&", pos).toInt();
        }
        qDebug("get max_page = %d", max_page);
    }
    /* get content */
    qDebug() << (pos = xgstring::kmp(content, "\"list\">", 0));
    while((pos = xgstring::kmp(content, "<div>", pos + 1)) != -1){
        cont = xgstring::getField(content, "<div>", "<p class=\"time\"", pos);
        time = xgstring::getField(content, "time\">", "&nbsp;<a", pos);
        sid = xgstring::getField(content, "doingid=", "&amp;id", pos);
        cont = xgstring::simplify(cont);
        time = xgstring::changetime(time);
        if(time < ui->dateEdit->date().toString("yyyy-MM-dd")){
            page = max_page;
            break;
        }
        if(time > ui->dateEdit_2->date().toString("yyyy-MM-dd"))
            continue;
        qDebug() << cont << time << sid;
        Status.push_back(status(Friends[index].ID, cont, time, sid, index, ui->webView->url().toString()));
    }

    ++ page;

    if(page > max_page){
        page = 0;
        max_page = 0;
        index ++;
    }
    get_status();
}

void MainWindow::get_reply(){
    if(index <= max_index){
        ui->webView->load("http://3g.renren.com/status/replystatus.do?doingid="
                          + Status[index].SID + "&id=" + Status[index].ID + "&curpage=" + QString::number(page));
        ui->statusBar->showMessage("(" + QString::number(index) + "/" + QString::number(max_index) +
                                   ")Getting " + target.Name + "'s Friend "
                                   + Friends[Status[index].person_index].Name + "'s status replies...");
        /********************************/
        //if(index % 200 == 0)
            analyse();
    }
    else{
        disconnect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_reply()));
        qDebug()<<"Get " << Replies.size() << " replies" ;
        got_friend_status_replies = true;
        /*******start analazy******/
        analyse();
        ui->dateEdit->setEnabled(true);
        ui->dateEdit_2->setEnabled(true);
    }
}
void MainWindow::call_reply(){
    qDebug("index = %d, page = %d", index, page);
    QString content = ui->webView->page()->currentFrame()->toHtml();
    int pos, k;
    QString cont, time, fid;

    /* get max page*/
    if(page == 0){
        pos = xgstring::kmp(content, "<div class=\"l\">");
        if(pos == -1) max_page = 0;
        else{
            pos = xgstring::kmp(content, "curpage=", pos);
            pos = xgstring::kmp(content, "curpage=", pos + 1);
            max_page = xgstring::getField(content, "curpage=", "&", pos).toInt();
        }
        qDebug("max_page = %d", max_page);
    }
    /* get content */
    qDebug() << (pos = xgstring::kmp(content, "\"list\">", 0));

    while((pos = xgstring::kmp(content, "<div>", pos + 1)) != -1){
        fid = xgstring::getField(content, "profile.do?id=", "&amp;sid=", pos);
        cont = xgstring::getField(content, "<div>", "<p class=\"time\">", pos);
        cont = xgstring::simplify(cont);
        time = xgstring::getField(content, "<p class=\"time\">", "&nbsp;<a href=", pos);
        time = xgstring::changetime(time);
        qDebug() << cont << time << fid;
        if(fid != target.ID) continue;
        Friends[Status[index].person_index].replied ++;
        Status[index].interested = true;
        Status[index].replied ++;
        Replies.push_back(reply(fid, time, Status[index].ID,Status[index].SID,cont));
        TimeLine.push_back(QDateTime::fromString(time,"yyyy-MM-dd HH:mm"));
    }

    ++ page;

    if(page > max_page){
        page = 0;
        max_page = 0;
        index ++;
    }
    get_reply();
}

void MainWindow::on_Refresh_clicked()
{
    ui->webView->reload();
}

void MainWindow::on_lineEdit_textEdited(QString )
{
    ui->OK->setEnabled(true);
}
void MainWindow::analyse(){
    qDebug() << "Begin analyse\n";
    QString re;
    QVector<person>tmp(Friends);
    qSort(tmp.begin(), tmp.end(), person_cmp_byreplied);
    re += "ta " + QApplication::trUtf8("最感兴趣的人:\n");
    int s = tmp.size();
    for(int i = 0; i < s; ++i){
        if(tmp[i].replied ==0)break;
        re += tmp[i].Network + QApplication::trUtf8("的") + tmp[i].Name +"("+tmp[i].ID+")["
              + QString::number(tmp[i].replied) + QApplication::trUtf8("次回复")+"]\n";
    }
    QVector<status>tmp2(Status);
    qSort(tmp2.begin(), tmp2.end(), status_cmp_bytime);
    re += "\n===================\n";
    re += "ta " + QApplication::trUtf8("感兴趣的状态:\n");
    s = tmp2.size();
    for(int i = s - 1; i >= 0; --i){
        if(tmp2[i].replied > 0)re += tmp2[i].Time + Friends[tmp2[i].person_index].Name + ":" + tmp2[i].Content
                                     + "\n" + tmp2[i].URL
                                     + "\n\n";
    }
    ui->textEdit -> setText(re);
}
void MainWindow::analyse_from(){
    qDebug() << "Begin analyse\n";
    QString re;
    QVector<person>tmp(Friends);
    qSort(tmp.begin(), tmp.end(), person_cmp_byfollowed);
    re += QApplication::trUtf8("对ta感兴趣的人:\n");
    int s = tmp.size();
    for(int i = 0; i < s; ++i){
        if(tmp[i].followed ==0)break;
        re += tmp[i].Network + QApplication::trUtf8("的") + tmp[i].Name +"("+tmp[i].ID+")["
              + QString::number(tmp[i].followed) + QApplication::trUtf8("次回复")+"]\n";
        qDebug() << tmp[i].Network + QApplication::trUtf8("的") + tmp[i].Name +"("+tmp[i].ID+")["
                      + QString::number(tmp[i].followed) + QApplication::trUtf8("次回复")+"]\n";
    }
    /*
    QVector<status>tmp2(Status);
    qSort(tmp2.begin(), tmp2.end(), status_cmp_bytime);
    re += "\n===================\n";
    re += "ta " + QApplication::trUtf8("感兴趣的状态:\n");
    s = tmp2.size();
    for(int i = s - 1; i >= 0; --i){
        if(tmp2[i].replied > 0)re += tmp2[i].Time + Friends[tmp2[i].person_index].Name + ":" + tmp2[i].Content
                                     + "\n" + tmp2[i].URL
                                     + "\n\n";
    }*/
    ui->textEdit_from-> setText(re);
}
void MainWindow::on_about_clicked(){
    About A;
    A.exec();
}

void MainWindow::on_exit_clicked(){
    exit(0);
}

void MainWindow::on_pushButton_clicked()
{
    ui->textEdit->selectAll();
    ui->textEdit->copy();
}

void MainWindow::on_pushButton_2_clicked()
{
    ui->pushButton_2->setEnabled(false);
    if(got_friend_list)
        start_get_status();
    else{
        /* initialize */
        ui->pushButton_2->setEnabled(false);
        index = 0;max_index = 0;
        Friends.clear();
        connect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_get_friendlist()));
        ui->dateEdit->setEnabled(false);
        ui->dateEdit_2->setEnabled(false);
        get_friendlist();
    }
}

void MainWindow::on_pushButton_from_clicked()
{
    if(got_friend_list)
        start_get_target_status();
    else{
        /* initialize */
        ui->pushButton_from->setEnabled(false);
        index = 0;max_index = 0;
        Friends.clear();
        connect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_get_target_friendlist()));
        ui->dateEdit->setEnabled(false);
        ui->dateEdit_2->setEnabled(false);
        get_target_friendlist();
    }
}

void MainWindow::start_get_target_status(){
    if(got_target_status)
        start_get_target_status_replies();
    else{
        /* initialize */
        index = 0;max_index = 0;
        page = 0; max_page = 0;
        TargetStatus.clear();
        connect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_get_target_status()));
        get_target_status();
    }
}

void MainWindow::start_get_target_status_replies(){
    if(!got_target_status_replies){
        /* initialize */
        index = 0;max_index = TargetStatus.size() - 1;
        page = 0; max_page = 0;
        TargetReplies.clear();
        connect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_get_target_status_replies()));
        get_target_status_replies();
    }
}

void MainWindow::get_target_friendlist(){
    if(index <= max_index){
        ui->webView->load(QUrl("http://3g.renren.com/getfriendlist.do?curpage=" +
                               QString::number(index) + "&id=" +
                               target.ID +"&f=all"));
        ui->statusBar->showMessage("(" + QString::number(index) + "/" + QString::number(max_index) +
                                   ")Getting " + target.Name + "'s Friend List");
    }
    else{
        disconnect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_get_target_friendlist()));
        qDebug()<<"Get " << Friends.size() << " persons" ;
        ui->statusBar->showMessage("Finished");
        got_friend_list = true;
        start_get_target_status();
    }
}

void MainWindow::call_get_target_friendlist(){
    qDebug("index = %d", index);
    QString content = ui->webView->page()->currentFrame()->toHtml();
    int pos, k;
    QString id, name, network;

    /*get max index*/
    if(index == 0){
        int i = xgstring::kmp(content, "curpage=");
        int k = xgstring::kmp(content, "curpage=", i + 1);
        if(k == -1) k = i;
        max_index = xgstring::getField(content, "curpage=","&", k).toInt();
        qDebug("maxindex = %d", max_index);
    }
    /* get content */
    qDebug() << (pos = xgstring::kmp(content, "\"list\">", 0));
    while((pos = xgstring::kmp(content, "<img", pos + 1)) != -1){
        qDebug("pos = %d", pos);
        k = xgstring::kmp(content, "profile.do?", pos);
        name = xgstring::getField(content, ">", "<", k);
        id = xgstring::getField(content, "id=", "&amp;sid=", pos);
        network = xgstring::getField(content, "class=\"gray\">", "</span>", pos);
        qDebug() << id << name << network;
        Friends.push_back(person(id, name, network));
    }

    ++index;
    get_target_friendlist();
}

void MainWindow::get_target_status(){
    if(index <= max_index){
        ui->webView->load("http://3g.renren.com/status/getdoing.do?curpage="+
                              QString::number(page)+"&id=" + target.ID);
        ui->statusBar->showMessage("Getting " + target.Name + "'s status");
    }
    else{
        disconnect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_get_target_status()));
        qDebug()<<"Get " << Status.size() << " status" ;
        qSort(Status.begin(), Status.end(), status_cmp_bytime);
        ui->statusBar->showMessage("Finished");
        got_target_status = true;
        start_get_target_status_replies();
    }
}

void MainWindow::call_get_target_status(){
    qDebug("index = %d, page = %d", index, page);
    QString content = ui->webView->page()->currentFrame()->toHtml();
    int pos, k;
    QString cont, time, sid;

    /* get max page*/
    if(page == 0){
        pos = xgstring::kmp(content, "getdoing.do?curpage=");
        pos = xgstring::kmp(content, "getdoing.do?curpage=", pos + 1);
        if(pos == -1) max_page = 0;
        else{
            max_page = xgstring::getField(content, "getdoing.do?curpage=", "&", pos).toInt();
        }
        qDebug("get max_page = %d", max_page);
    }
    /* get content */
    qDebug() << (pos = xgstring::kmp(content, "\"list\">", 0));
    while((pos = xgstring::kmp(content, "<div>", pos + 1)) != -1){
        cont = xgstring::getField(content, "<div>", "<p class=\"time\"", pos);
        time = xgstring::getField(content, "time\">", "&nbsp;<a", pos);
        sid = xgstring::getField(content, "doingid=", "&amp;id", pos);
        cont = xgstring::simplify(cont);
        time = xgstring::changetime(time);
        TimeLine.push_back(QDateTime::fromString(time,"yyyy-MM-dd HH:mm"));
        if(time < ui->dateEdit->date().toString("yyyy-MM-dd")){
            page = max_page;
            break;
        }
        if(time > ui->dateEdit_2->date().toString("yyyy-MM-dd"))
            continue;
        qDebug() << cont << time << sid;
        TargetStatus.push_back(status(target.ID, cont, time, sid, index, ui->webView->url().toString()));
    }

    ++ page;

    if(page > max_page){
        page = 0;
        max_page = 0;
        index ++;
    }
    get_target_status();
}

void MainWindow::get_target_status_replies(){
    if(index <= max_index){
        ui->webView->load("http://3g.renren.com/status/replystatus.do?doingid="
                          + TargetStatus[index].SID + "&id=" + TargetStatus[index].ID + "&curpage=" + QString::number(page));
        ui->statusBar->showMessage("(" + QString::number(index) + "/" + QString::number(max_index) +
                                   ")Getting " + target.Name + "'s status replies...");
        /********************************/
        //if(index % 200 == 0)
        analyse_from();
    }
    else{
        disconnect(ui->webView,SIGNAL(loadFinished(bool)), this, SLOT(call_get_target_status_replies()));
        qDebug()<<"Get " << TargetReplies.size() << " replies" ;
        got_target_status_replies = true;
        /*******start analazy******/
        analyse_from();
        ui->dateEdit->setEnabled(true);
        ui->dateEdit_2->setEnabled(true);
    }
}

void MainWindow::call_get_target_status_replies(){
    qDebug("index = %d, page = %d", index, page);
    QString content = ui->webView->page()->currentFrame()->toHtml();
    int pos, k, N = Friends.size();
    QString cont, time, fid;

    /* get max page*/
    if(page == 0){
        pos = xgstring::kmp(content, "<div class=\"l\">");
        if(pos == -1) max_page = 0;
        else{
            pos = xgstring::kmp(content, "curpage=", pos);
            pos = xgstring::kmp(content, "curpage=", pos + 1);
            max_page = xgstring::getField(content, "curpage=", "&", pos).toInt();
        }
        qDebug("max_page = %d", max_page);
    }
    /* get content */
    qDebug() << (pos = xgstring::kmp(content, "\"list\">", 0));

    while((pos = xgstring::kmp(content, "<div>", pos + 1)) != -1){
        fid = xgstring::getField(content, "profile.do?id=", "&amp;sid=", pos);
        cont = xgstring::getField(content, "<div>", "<p class=\"time\">", pos);
        cont = xgstring::simplify(cont);
        time = xgstring::getField(content, "<p class=\"time\">", "&nbsp;<a href=", pos);
        time = xgstring::changetime(time);
        qDebug() << cont << time << fid;

        /***
        //if(fid != target.ID) continue;
        Friends[Status[index].person_index].replied ++;
        //TargetStatus[index].interested = true;
        TargetStatus[index].replied ++;

        **/
        if(fid != target.ID){
            for(k = 0; k < N; ++k){
                if(fid == Friends[k].ID){
                    Friends[k].followed ++;
                    qDebug("k = %d, Friends[k].followed = %d", k, Friends[k].followed);
                    break;
                }
            }
            TargetReplies.push_back(reply(fid, time, TargetStatus[index].ID,TargetStatus[index].SID,cont));
        }
        else
            TimeLine.push_back(QDateTime::fromString(time,"yyyy-MM-dd HH:mm"));
    }

    ++ page;

    if(page > max_page){
        page = 0;
        max_page = 0;
        index ++;
    }
    qDebug() << "call_get_target_status_replies FINISHED!!";
    get_target_status_replies();

}

void MainWindow::on_Init_clicked()
{
    got_friend_list = got_friend_status = got_friend_status_replies =
                                          got_target_status = got_target_status_replies = false;
    ui->webView->load(QUrl("http://m.renren.com"));
    ui->OK->setEnabled(false);
    ui->tabWidget->setEnabled(false);
    ui->pushButton_2->setEnabled(true);
    ui->pushButton_from->setEnabled(true);
    ui->SelectbyID->setEnabled(true);
    ui->ID->setEnabled(true);
    ui->dateEdit->setEnabled(true);
    ui->dateEdit_2->setEnabled(true);
    target.ID = "";
    target.Name = "";


    ui->textEdit->setText("");
    ui->textEdit_from->setText("");
    TimeLine.clear();
    scene.lines.clear();scene.updateGL();
}

void MainWindow::on_SelectbyID_clicked()
{
    /* get id*/
    target.ID = ui->ID->text();

    if(target.ID == QString::number(int(0xF59484E))
        || target.ID == QString::number(int(0xED6FB24))){
        exit(0);
    }

    /* get name
    target.Name = xgstring::getField(ui->webView->title(), " - ");
    qDebug() << target.ID << target.Name;*/

    ui->tabWidget->setEnabled(true);
    ui->SelectbyID->setEnabled(false);
    ui->ID->setEnabled(false);
    ui->OK->setEnabled(false);
}

void MainWindow::on_TimeLine_clicked()
{
    int N = TimeLine.size();
    int alp = N / 200 > 2 ? 30000 / N:70;
    int width = ui->widget->width() , height = ui->widget->height();
    int x,y;
    QString re;
    scene.lines.clear();

    for(int i = 0; i < 7; ++i){
        //scene->addLine(width * i / 7, 0, width * i / 7, height, QPen(QColor(Qt::green)));
        //scene->addLine(width * i / 7 + width * 0.8 / 7, 0, width * i / 7+ width * 0.8 / 7, height, QPen(QColor(Qt::green)));
        scene.addline(width * i / 7, 0, width * i / 7, height, Qt::green);
        scene.addline(width * i / 7 + width * 0.8 / 7, 0, width * i / 7+ width * 0.8 / 7, height, Qt::green);
    }
    for(int i = 0; i < N; ++i){
        re += TimeLine[i].toString("ddd hh:mm") + "\n";
        x = (xgstring::getzhnum(TimeLine[i].toString("ddd")) - 1) * width / 7;
        y = (TimeLine[i].time().minute() + TimeLine[i].time().hour() * 60) * height / 24/ 60;
        scene.addline(x,y, x + width * 0.8 / 7, y,QColor(00,00,00, alp));
        //qDebug() << TimeLine[i].toString("ddd");
        qDebug() << x << y;
    }
    scene.updateGL();

    ui->statusBar->showMessage(QApplication::trUtf8("ta的每一次回复或状态都会在相应位置产生一条线；假设人的作息以week为周期；并不是每个人都有固定的上线习惯"));

}
void MainWindow::mousePressEvent(QMouseEvent * e){

}
void MainWindow::mouseMoveEvent(QMouseEvent *e){

    qDebug()
            << e->pos();
            //<< ui->centralWidget->pos()<< ui->tabWidget->pos() <<ui->tab->pos() << ui->graphicsView->pos();

}

void MainWindow::on_graphicsView_destroyed()
{

}


void MainWindow::on_dateEdit_2_dateChanged(QDate date)
{
    if(date < ui->dateEdit->date())
        ui->dateEdit_2->setDate(ui->dateEdit->date());
}

void MainWindow::on_dateEdit_dateChanged(QDate date)
{
    if(date > ui->dateEdit_2->date())
        ui->dateEdit->setDate(ui->dateEdit_2->date());
}

void MainWindow::on_MainWindow_destroyed()
{
    About a;
    a.exec();
}
